﻿using Brjnk.GpxExplorer.ViewModel;

namespace Brjnk.GpxExplorer.Computing
{
    internal class RouteCalculationContext
    {
        private RoutePointVM previous;

        internal void AddPoint(RoutePointVM point)
        {
            Number++;

            if (previous != null)
            {
                Azimuth = Brjnk.Common.Azimuth.GetAzimuth(previous.Source.Position, point.Source.Position);
                DistanceDelta = previous.Source.Position - point.Source.Position;
                Distance = previous.Distance + DistanceDelta;
            }
            else
            {
                Azimuth = null;
                Distance = 0;
                DistanceDelta = 0;
            }

            previous = point;
        }

        public Common.Azimuth? Azimuth { get; private set; }

        public Common.Distance Distance { get; private set; }

        public Common.Distance DistanceDelta { get; private set; }

        public int Number { get; set; }
    }
}